1
/****************************** Module Header ******************************\
2 * Module Name: WCFService.cs
3 * Project: CSAzureWCFServices
4 * Copyright (c) Microsoft Corporation.
6 * This class implements WCFService.IContract interface.
7 * Methods directly returns information about the current work role.
9 * This source is subject to the Microsoft Public License.
10 * See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
11 * All other rights reserved.
13 * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
14 * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
15 * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
16 \***************************************************************************/
20 using Microsoft
.WindowsAzure
;
21 using Microsoft
.WindowsAzure
.Diagnostics
;
22 using Microsoft
.WindowsAzure
.ServiceRuntime
;
23 using System
.ServiceModel
;
27 // Implement the wcf contract WCFContract.IContract
28 class WCFService
:WCFContract
.IContract
30 // Return the current work role's name and instance id
31 public string GetRoleInfo()
33 RoleInstance currentRoleInstance
= RoleEnvironment
.CurrentRoleInstance
;
34 string RoleName
= currentRoleInstance
.Role
.Name
;
35 string RoleInstanceID
= currentRoleInstance
.Id
;
36 return (string.Format("You are talking to role {0}, instance ID {1}\n.", RoleName
, RoleInstanceID
));
39 // Return the channel between the client & the work role
40 public string GetCommunicationChannel()
42 return (string.Format("You are talking via {0}.", OperationContext
.Current
.Channel
.LocalAddress
.Uri
.ToString()));